package demo1228.homework;

import java.io.*;

/*
使用缓冲字节流完成图片的复制
 */
public class Demo_02 {
    public static void main(String[] args) {

        try (BufferedInputStream bis = new BufferedInputStream(new FileInputStream("1.png"));
             BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("A.png"))
        ) {
            int read;
            byte[] bs = new byte[1024];
            while ((read = bis.read(bs)) != -1) {
                bos.write(bs, 0, read);
            }

            bos.flush();

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
